package com.ea.eadp.nexus.test.workflow.pc.register;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import com.ea.eadp.nexus.test.pageDefinition.Signup_PC;
import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;

public class InputDobWorkflowElement extends WorkflowElement {
    
    protected Signup_PC page;
    
    public InputDobWorkflowElement(
        WebDriver driver,
        WorkflowElementArgument args
    ) {
        super(driver, args);
        page = new Signup_PC(driver);
    }
    
    @Override
    public void init() {
        super.init();
        page.navigate();
        page.waitForWebElementPresent( By.id("continue-btn") );
    }
    
    @Override
    public void doAction() {
        try {
            page.setDobMonth(args.dobMonth);
            page.setDobDay(args.dobDay);
            page.setDobYear(args.dobYear);
            page.setRegisterCountry( args.country.name() );
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    
    @Override
    public void moveNext() {
        WebElement continueBtn = driver.findElement(
            By.id("continue-btn")
        );
        continueBtn.click();
    }
    
}
